var remoteUrl = "http://www.shengtangzhongguo.com/";
function requestPost(url, data, header) {
    if (typeof url === "undefined" || typeof data === "undefined") {
        return new Promise(function (resolve, reject) {
            resolve({
                code: 0,
                msg: '缺少请求地址或请求参数'
            })
        });
    }
    if (typeof remoteUrl === "undefined" || !remoteUrl) {
        return new Promise(function (resolve, reject) {
            resolve({
                code: 0,
                msg: '缺少请求地址或请求参数'
            })
        });
    }
    if (typeof data._ajax === "undefined" || data._ajax !== 1) {
        data._ajax = 1;
    }
    if (typeof header !== "object") {
        header = {}
    }

    header['Content-Type'] = 'application/json';

    data.jiami = -1;//-1不加密，1是加密
    return new Promise(function (resolve, reject) {
        var thatdata = data;
        var thaturl = url;
        
        $.post(remoteUrl + thaturl, data,function(ret) {
            if (ret.code == 0) {
                if (ret.msg === '请先登录' || ret.msg === '请登录后再试') {
                } else if (ret.msg === '拒绝访问') {
                    reject({
                        code: 0,
                        msg: ''
                    });
                } else {
                    resolve(ret);
                }
            } else {
                resInfo = ret.data;
                resolve(resInfo);
            }
        }, "json");
    });
}
